package org.alex.netShop.pages;

import java.util.LinkedList;



import org.alex.netShop.beans.ProductBean;
import org.alex.netShop.interfaces.Product;
import org.alex.netShop.interfaces.Products;
import org.alex.netShop.interfaces.Purchase;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SetupRender;
import org.apache.tapestry5.ioc.annotations.Inject;

public class AddProduct
{
	@Persist
	@Property
	private Product product;
	
	@InjectPage
	private ViewProduct viewProductPage;
	@InjectPage
	private Error errorPage;
	
	@Inject
	private Products products;
	
	@SetupRender
	public void createObject() {
		product = new ProductBean();
		product.setPurchase(new LinkedList<Purchase>());
	}

	void onSuccess() {
		products.save(product);
	}
	

}
